<template>
  <div class="custom_goods_list">
    <h1 class="custom_goods_list_header" v-if="item.title">
      <div class="custom_goods_list_header_title">{{ item.title }}</div>
      <div class="custom_goods_list_header_slogan">{{ item.slogan }}</div>
      <div><slot name="right"></slot></div>
    </h1>
    <div class="custom_goods_list_content">
      <GoodsListTools :item="item"></GoodsListTools>
      <div class="custom_goods_list_content_items" v-if="item.data.length > 0">
        <div v-for="(good, index) in item.data" :key="'goodsList_' + index">
          <GoodsListItem
            :item="good"
            :index="index"
            :type="item.type"
          ></GoodsListItem>
        </div>
      </div>
      <div v-else class="custom_goods_list_content nodata">
        <span>{{ $t("lang.暂无数据") }}</span>
      </div>
      <div
        class="loadmore"
        v-if="!isDownLoadMore && !isLoading && item.data.length > 0"
      >
        <a href="javascript:;" @click="loadMoreClickHandle">{{
          $t("lang.点击加载更多")
        }}</a>
      </div>
      <div class="loading" v-if="isLoading">
        <van-loading size="24px">{{ $t("lang.加载中") }}</van-loading>
      </div>
    </div>
  </div>
</template>
<script>
export default {
  name: "goodsList",
  props: {
    item: {
      type: Object,
      default() {
        return {};
      },
    },
    isDownLoadMore: {
      type: Boolean,
      default() {
        return false;
      },
    },
  },
  components: {
    GoodsListTools: () =>
      import(
        /* webpackChunkName:'goodsListTools' */ "../../components/listPinterest/goodsListTools"
      ),
    GoodsListItem: () =>
      import(
        /* webpackChunkName:'goodsListItem' */ "../../components/listPinterest/goodsListItem"
      ),
  },
  data() {
    return {
      isLoading: false,
    };
  },
  methods: {
    loadMoreClickHandle() {
      this.$parent.$emit("loadMore", true);
    },
  },
};
</script>
<style lang="less">
@base: 23.44rem;
.custom_goods_list {
  h1 {
    &.custom_goods_list_header {
      height: (15 / @base);
      font-size: (14 / @base);
      line-height: (14 / @base);
      text-align: left;
      padding: (10 / @base) (10 / @base);
      border-bottom: (1 / @base) solid #efefef;
      display: flex;
      overflow: hidden;
      color: #333;
      font-weight: 400;
      div {
        width: 10%;
        &.custom_goods_list_header_title {
          width: 25%;
          line-height: (14 / @base);
          overflow: hidden;
          height: (15 / @base);
        }
        &.custom_goods_list_header_slogan {
          width: 65%;
          font-size: (12 / @base);
          line-height: (14 / @base);
          color: #ccc;
          margin: 0 0 0 (10 / @base);
          font-weight: 400;
        }
      }
    }
  }
  .custom_goods_list_content {
    &.nodata {
      span {
        display: block;
        text-align: center;
        font-size: (14 / @base);
        margin: 0 auto;
        line-height: (100 / @base);
      }
    }
    .custom_goods_list_content_items {
    }
  }
  .loading {
    padding: (10 / @base) 0 (20 / @base) 0;
  }
  .loadmore {
    clear: both;
    font-size: (14 / @base);
    margin: (5 / @base);
    text-align: center;
    /*     background-color: #fff;
    box-shadow: 0 2px 12px rgba(100, 101, 102, 0.12);
 */
    border-radius: (2.5 / @base);
    a {
      padding: (10 / @base);
      color: #999;
      display: block;
    }
  }
}
</style>
